package com.jt.www.admin.caseinfo.controller;

import com.jt.www.admin.caseinfo.service.CaseInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "案件相关接口", tags = {"CASE-INFO-API"}, description = "案件相关接口")
@RestController
@RequestMapping(value = "/case")
public class CaseInfoController {

    public static final Logger log = LoggerFactory.getLogger(CaseInfoController.class);
    @Autowired
    private CaseInfoService caseInfoService;


    @ApiOperation(value = "查询案件审核人员列表", notes = "查询案件审核人员列表", httpMethod = "GET")
    @GetMapping(value = "/queryAuditors", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public ResponseEntity queryAuditors(@ApiParam(value = "分支机构编码", required = true) @RequestParam("branchCode") String branchCode,
                                        @ApiParam(value = "角色编码", required = true) @RequestParam("roleCode") String roleCode,
                                        @ApiParam(value = "是否递归查询", required = true) @RequestParam("isRecursion") Boolean isRecursion) {

        String findCode = "queryAuditors_" + System.currentTimeMillis();

        log.info("{} 案件查询分支机构审核人员列表 入参：branchCode->{},roleCode->{},isRecursion->{}", findCode, branchCode, roleCode, isRecursion);

        return caseInfoService.queryAuditors(findCode, branchCode, roleCode, isRecursion);
    }

    @ApiOperation(value = "查询某机构下级分支机构列表", notes = "查询某机构下级分支机构列表", httpMethod = "GET")
    @GetMapping(value = "/queryThirdGradeBranch", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public ResponseEntity queryThirdGradeBranch(@ApiParam(value = "分支机构编码", required = true) @RequestParam("branchCode") String branchCode,
                                                @ApiParam(value = "分支机构名称", required = true) @RequestParam("branchName") String branchName) {

        String findCode = "queryThirdGradeBranch_" + System.currentTimeMillis();

        log.info("{} 查询某机构下级分支机构列表 入参：branchCode->{},branceName->{}", findCode, branchCode, branchName);

        return caseInfoService.queryThirdGradeBranch(findCode, branchCode, branchName);
    }

    @ApiOperation(value = "判断出险人是否在清单内", httpMethod = "GET")
    @GetMapping(value = "/isInclude", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResponseEntity<?> isInclude(@ApiParam(value = "投保单号", required = true) @RequestParam("insuranceId") String insuranceId,
                                       @ApiParam(value = "出险人证件号码(多个以,分隔)", required = true) @RequestParam("licenceNos") String licenceNos) {
        return caseInfoService.isInclude(insuranceId, licenceNos);
    }
}
